package top.lingma.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.converter.FormHttpMessageConverter;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.StringHttpMessageConverter;
import org.springframework.web.client.RestTemplate;

import java.nio.charset.Charset;

/**
 * @author yui
 * @date 2019年04月03日 上午10:59
 */

@Configuration
public class RestTemplateConfig {


    @Bean
    RestTemplate restTemplate() {
        RestTemplate ret = new RestTemplate();
        HttpMessageConverter formHttpMessageConverter = new FormHttpMessageConverter();
        HttpMessageConverter stringHttpMessageConverternew = new StringHttpMessageConverter(Charset.forName("UTF-8"));
        ret.getMessageConverters().add(formHttpMessageConverter);
        ret.getMessageConverters().add(stringHttpMessageConverternew);
        return ret;
    }
}
